﻿@using Shop.Entity;
@using Shop.Help;
@using Shop.Bll;
@using System.Data;
@using Shop.Help;
@using Webdiyer.WebControls.Mvc;
@{
    Layout = null;
    string serverPath = Safe.GetWebConfigValueByKey("ServerPath");
}
@model  PagedList<DataRow>


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>列表</title>
    <link href="@Url.Content("/Content/admin/css/bootstrap.min.css")" rel="stylesheet" />
    <script src="/Scripts/jquery-1.10.2.min.js"></script>
    <script src="~/Content/admin/js/bootstrap.min.js"></script>
    <script src="~/Content/My97DatePicker/WdatePicker.js"></script>

    <style>
        .navbar-form {
            padding: 0;
        }

        th {
            text-align: center;
        }
    </style>
</head>
<body>
    <div class="container-fluid">
        <ol class="breadcrumb">
            <li><a href="/set/admin/center">首页></a></li>
            <li><a href="#">限时抢购></a></li>
            <li class="active">抢购订单</li>
        </ol>
        <form class="navbar-form navbar-left" id="formSearch" role="form" action="/groupbuy/rushorder/list">
            <input type="hidden" name="PageSize" value="15" />
            <div class="form-group">
                @Html.DropDownList("Business", ViewData["Business"] as IEnumerable<SelectListItem>, "-选择商户-", new { @class = "form-control input-sm" })
            </div>
            <div class="form-group">
                <input type="text" class="form-control input-sm" id="SearchTitle" name="OrderNumber" placeholder="请输入订单号" />
            </div>
            <input type="text" class="form-control input-sm" name="TimeFrom" id="TimeFrom" placeholder="下单时间" onclick="WdatePicker();" />
            至
            <input type="text" class="form-control input-sm" name="TimeTo" id="TimeTo" placeholder="下单时间" onclick="WdatePicker({ minDate: '#F{$dp.$D(\'TimeFrom\')}' });" />
            <button type="submit" class="btn btn-primary btn-sm ">
                <span class="glyphicon glyphicon-zoom-in" aria-hidden="true"></span>&nbsp;搜索
            </button>
        </form>

        <div id="divTable">
            <table class="table table-bordered  table-hover table-condensed" id="treeTable1">
                <thead>
                    <tr>
                        <th></th>
                        <th>下单时间</th>
                        <th>订单号</th>
                        <th>抢购商品</th>
                        <th>会员姓名</th>
                        <th>会员手机号</th>
                        <th>所属商户</th>
                        <th>订单总额</th>
                        <th>支付方式</th>
                        <th>订单状态</th>
                        <th class="hidden-xs">操作</th>
                    </tr>
                </thead>

                <tbody>
                    @foreach (DataRow item in Model)
                    {
                        <tr id="@(item["Guid"])" role="button" data-toggle="collapse" data-target="#@(item["Guid"])tr" aria-expanded="false" aria-controls="@(item["Guid"])tr">

                            <td><span id="@(item["Guid"])span" class="glyphicon  glyphicon-plus" style="font-size:smaller;" aria-hidden="true"></span></td>
                            <td>@Convert.ToDateTime(item["CreateTime"]).ToString("yyyy-MM-dd HH:MM")</td>
                            <td class="title">@item["OrderNumber"]</td>
                            @if (item["Title"].ToString().Length >= 20)
                            {
                                <td id="@item["Guid"]">@item["Title"].ToString().Substring(0, 20)  ...</td>
                            }
                            else
                            {
                                <td>@item["Title"]</td>
                            }

                            <td>@item["Name"]</td>
                            <td>@item["Mobile"]</td>
                            <td>@item["BusinessName"]</td>
                            <td>￥@item["TotalPay"]</td>

                            <td>微信支付</td>
                            @switch (item["Status"].ToString())
                            {
                                case "0":
                                    <td>已付款</td>
                                    break;
                                default:
                                    break;
                            }
                            <td></td>

                        </tr>

                        <tr id="@item["Guid"]tr" class="collapse" data-guid="@item["Guid"]">

                            <td colspan="10">
                                <table class="table table-condensed">
                                    <caption>订单明细&nbsp;&nbsp;<mark>(合计:93.4元)</mark></caption>
                                    <thead>
                                        <tr>
                                            <th>商品</th>
                                            <th>价格</th>
                                            <th>数量</th>
                                            <th>总价</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td>速冻水饺</td>
                                            <td>12.6</td>
                                            <td>3</td>
                                            <td>37.8</td>
                                        </tr>
                                    </tbody>
                                </table>
                                <p><mark>备注:</mark>这个订单请尽快配送，我等着用的哈，谢谢啦，麻烦快些了！</p>
                            </td>
                        </tr>
                    }
                </tbody>

            </table>
            <div class="col-xs-9" style="width:auto;padding-left:0px;">
                <ul class="pagination">
                    <li>
                        <span aria-hidden="true">
                            @(Model.PageSize)条/页，@(Model.TotalPageCount)页, 共@(Model.TotalItemCount)条
                        </span>
                    </li>
                    <li>
                        <span aria-hidden="true">
                            每页
                            <select style="border-radius:4px;font-family:normal;vertical-align: text-bottom;" id="PageSize" name="PageSize" onchange="PageSizeChange();">

                                <option selected="selected" value="15">15</option>
                                <option value="20">20</option>
                                <option value="30">30</option>
                            </select>
                            条
                        </span>
                    </li>
                </ul>
                @Ajax.Pager(Model,
                new PagerOptions
                {
                    PageIndexParameterName = "pageIndex",
                    CssClass = "pagination",
                    FirstPageText = "首页",
                    LastPageText = "尾页",
                    PrevPageText = "上一页",
                    PageIndexBoxId = "pageIndexBox",
                    GoToButtonId = "Go",
                    PageIndexOutOfRangeErrorMessage = "页码有误!",
                    NumericPagerItemCount = 8,
                    NextPageText = "下一页",
                    CurrentPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>",
                    DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>",
                    PagerItemTemplate = "<li>{0}</li>",
                    AutoHide = false,

                }, new MvcAjaxOptions
                {
                    UpdateTargetId = "divTable",
                    HttpMethod = "Post",
                    DataFormId = "formSearch",
                    EnableHistorySupport = false,
                    OnSuccess = "Success();",
                    EnablePartialLoading = true
                }
                )
            </div>
            <div class="pagination" style="width:20%;margin-top: 0px;">
                <ul class="pagination">
                    <li>
                        <div class="input-group">
                            <span class="input-group-addon">第</span>
                            <input type="text" id="pageIndexBox" class="form-control input-sm" placeholder="" aria-describedby="sizing-addon2" oninput="InputPageIndex(this);">
                            <span class="input-group-addon">页</span>
                            <span class="input-group-btn">
                                <button class="btn btn-primary btn-sm" id="Go" type="button">Go</button>
                            </span>
                        </div>
                    </li>
                </ul>
            </div>

            <script type="text/javascript">

                function Success()
                {
                    var txt = $("#SearchTitle").val().trim();
                    if (txt.length > 0)
                    {
                        $(".title").each(function ()
                        {
                            var newTxt = $(this).html().replace(txt, txt.fontcolor("red"));
                            $(this).html(newTxt);
                        });
                    }
                    $("input[name='PageSize']").val('@ViewData["NowPageSize"]');
                    $("#PageSize").val(@ViewData["NowPageSize"]);
                }


                $('.collapse').on('shown.bs.collapse', function () {
                    // do something…
                    var guid = $(this).attr("data-guid");
                    $("#" + guid+"span").attr("class", "glyphicon  glyphicon-minus");

                })

                $('.collapse').on('hidden.bs.collapse', function () {
                    // do something…
                    var guid = $(this).attr("data-guid");
                    $("#" + guid + "span").attr("class", "glyphicon  glyphicon-plus");               
                })
            </script>
        </div>

    </div>
    @{Html.RegisterMvcPagerScriptResource();}
    <script src="/Content/LwsJS/List.js"></script>
    <script type="text/javascript">

                function ShowMsg(id, msg) {
                    parent.layer.tips(msg, "#" + id, {
                        tips: [2, '#3595CC'],
                        time: 4000
                    });
                    $("#" + id).mouseout(function () {
                        layer.closeAll('tips'); //关闭所有的tips层
                    });
                }
                function PageSizeChange() {
                    $("input[name='PageSize']").val($("#PageSize").val());
                    $("#formSearch").submit();
                }
                function MouseShowImage(obj) {
                    parent.layer.closeAll();
                    parent.layer.open({
                        type: 5,
                        title: false,
                        closeBtn: 0,
                        shade: 0,
                        content: "<img src='" + $(obj).attr("src") + "'/>"
                    });
                    $(obj).mouseout(function () {
                        parent.layer.closeAll();
                    });
                }
                function InputPageIndex(obj) {
                    var pageIndex = $(obj).val().trim();
                    if (parseInt(pageIndex) > parseInt($("#TotalPageCount").val())) {
                        $(obj).val($("#TotalPageCount").val());
                    }
                }
                function GoPageIndex() {
                    var pager = Webdiyer.MvcPagers[0];
                    var pageIndex = $("#pageIndexBox").val().trim();
                    var TotalPageCount = $("#TotalPageCount").val().trim();
                    if (parseInt(pageIndex) > parseInt(TotalPageCount)) {
                        pageIndex = TotalPageCount;
                    }
                    if (pager != null) {
                        pager.goToPage(parseInt(pageIndex));
                    } else
                    { alert("找不到指定的MvcPager！"); }
                }
    </script>
</body>
</html>